const autoprefixer = require('autoprefixer')
const pxtorem = require('postcss-pxtorem')
const path = require('path')

console.info(process.env.NODE_ENV)

function resolve(dir) {
    return path.join(__dirname, dir)
}

module.exports = {
    lintOnSave: true,
    productionSourceMap: false, // 去掉打包后js中，会自动生成的一些map文件
    devServer: {
        port: 7776, // 端口
        proxy: {
            '/common': {
                target: 'http://47.103.5.136:9494',
                // target: 'http://10.10.10.199:9090',
                changeOrigin: true, // target是域名的话，需要这个参数，
                secure: false, // 设置支持https协议的代理
                pathRewrite: { '^/common': '' }
            },
        }
    },
    chainWebpack: (config) => {
        config.resolve.alias
            .set('@', resolve('src'))
            .set('@assets', resolve('src/assets'))
            .set('@styles', resolve('src/styles'))
    },
    css: {
        loaderOptions: {
            postcss: {
                plugins: [
                    autoprefixer({
                        browsers: ['Android >= 4.0', 'iOS >= 7']
                    }),
                    pxtorem({
                        rootValue: 50,
                        unitPrecision: 3,
                        propList: ['*', '!font*'],
                        selectorBlackList: ['.ignore ', '.hairlines', 'van-circle__layer', '.van-hairline'],
                        minPixelValue: 2
                    })
                ]
            }
        }
    }
}
